package java实验六;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class 程序五 {
    private static final int NUM_OF_DAYS = 10;
	private static final int NUM_OF_HOURS = 24;

	public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(new File("weather_data.txt"));
        double[] dailyTemperatures = new double[NUM_OF_DAYS * NUM_OF_HOURS];
        double[] dailyHumidities = new double[NUM_OF_DAYS * NUM_OF_HOURS];

        for (int k = 0; k < NUM_OF_DAYS * NUM_OF_HOURS; k++) {
            dailyTemperatures[k] = sc.nextDouble();
            dailyHumidities[k] = sc.nextDouble();
        }

        sc.close();

        // Find the average daily temperature and humidity
        double dailyTemperatureTotal = 0;
        double dailyHumidityTotal = 0;
        for (int j = 0; j < NUM_OF_HOURS; j++) {
            for (int i = 0; i < NUM_OF_DAYS; i++) {
                dailyTemperatureTotal += dailyTemperatures[j * NUM_OF_DAYS + i];
                dailyHumidityTotal += dailyHumidities[j * NUM_OF_DAYS + i];
            }
        }

        // Display result
        System.out.println("The average daily temperature is " + dailyTemperatureTotal / (NUM_OF_DAYS * NUM_OF_HOURS) + ".");
        System.out.println("The average daily humidity is " + dailyHumidityTotal / (NUM_OF_DAYS * NUM_OF_HOURS) + ".");
    }
}
